<?php

use yii\db\Migration;

class m210915_111731_minerva_auth_node extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%minerva_auth_node}}', [
            'id' => "bigint(20) unsigned NOT NULL AUTO_INCREMENT",
            'auth' => "bigint(20) unsigned NULL DEFAULT '0' COMMENT '角色'",
            'node' => "varchar(200) NULL DEFAULT '' COMMENT '节点'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='大数据系统-授权'");
        
        /* 索引设置 */
        $this->createIndex('idx_rf_minerva_auth_auth','{{%minerva_auth_node}}','auth',0);
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%minerva_auth_node}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

